﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace road2.Model
{
    public class CarClass : BaseRoadObj//, IEqualityComparer<CarClass>
    {
        private RoadClass _road;
        public RoadClass Road
        {
            get { return _road; }
            set { _road = value; RaisePropertyChanged("Road"); }
        }

        private int _line;
        public int Line
        {
            get { return _line; }
            set
            {
                if (value < 0 || value >= this.Road.LineCount)
                {
                    throw new ArgumentOutOfRangeException("Line", "Current line is out of road lines");
                }
                _line = value; RaisePropertyChanged("Line");
            }
        }

        private int _distance;
        public int Distance
        {
            get { return _distance; }
            set { _distance = value; RaisePropertyChanged("Distance"); }
        }

        private int _currentSpeed;
        public int CurrentSpeed
        {
            get { return _currentSpeed; }
            set { _currentSpeed = value; RaisePropertyChanged("CurrentSpeed"); }
        }

        private int _maxSpeed;
        public int MaxSpeed
        {
            get { return _maxSpeed; }
            set { _maxSpeed = value; RaisePropertyChanged("SpeedLimit"); }
        }

        private Color _color;
        public Color Color
        {
            get { return _color; }
            set { _color = value; RaisePropertyChanged("Color"); }
        }

        public CarClass(Guid id):base(id)
        {

        }

        public void Drive()
        {
            this.Drive(this.CurrentSpeed);
        }

        public void Drive(int delta)
        {
            this.Distance += delta;
        }

        /*public bool Equals(CarClass x, CarClass y)
        {
            return x.id == y.id;
        }

        public int GetHashCode(CarClass obj)
        {
            return obj.id.GetHashCode();
        }*/
    }
}
